<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"> 
  <meta name="”renderer”" content="”webkit”"> 
  <meta http-equiv="”X-UA-Compatible”" content="”IE=Edge,chrome=1″"> 
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
  <title>乐直播-直播间</title> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/staticRep/layui/css/layui.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/static/portal/css/le-main24.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/static/libs/font-awesome/css/font-awesome.min.css?cdnv=0.16"> 
  <style type="text/css">
    .le-marketing-table tr{
        border-top: 1px solid #eaeaea;
    }
    .layui-textarea {width: 100%;}

    .le-marketing-table{
        margin:20px 0 10px 10px;
    }
        </style> 
  <script src="http://cdn.lezhibo.com/static/portal/js/fastclick.js?cdnv=0.16"></script> 
 </head> 
 <body> 
  <div class="le-main"> 
<%@include file="portal_navi.jsp" %>
  </div> 
  <div class="le-content-wrap le-head-content"> 
   <div class="le-sidebar"> 
    <ul class="layui-nav layui-nav-tree"> 
     <li class="layui-nav-item" id="info"><a href="${ctx}/portal/liveroom/info.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-cog" aria-hidden="true"></i>&nbsp;基础设置</a></li> 
     <li class="layui-nav-item" id="recommend"><a href="${ctx}/portal/liveroom/recommend.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-share" aria-hidden="true"></i>&nbsp;推荐设置</a></li> 
     <li class="layui-nav-item" id="selfTemplate"><a href="${ctx}/portal/liveroom/selfTemplate.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-comment-o" aria-hidden="true"></i>&nbsp;发送模板消息</a></li> 
     <li class="layui-nav-item" id="preview"><a href="${ctx}/portal/liveroom/preview.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-caret-square-o-right" aria-hidden="true"></i>&nbsp;直播间预览</a></li> 
     <li class="layui-nav-item" id="vip"><a href="${ctx}/portal/liveroom/vip.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-diamond" aria-hidden="true"></i>&nbsp;VIP设置</a></li> 
     <li class="layui-nav-item" id="userDuration"><a href="${ctx}/portal/liveroom/vipUserDeadline.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-list-alt" aria-hidden="true"></i>&nbsp;VIP会员列表</a></li> 
     <li class="layui-nav-item" id="auth"><a href="${ctx}/portal/liveroom/vipAuthRecord.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-th-list" aria-hidden="true"></i>&nbsp;VIP认证记录</a></li> 
     <li class="layui-nav-item" id="vipCombo"><a href="${ctx}/portal/liveroom/vipCombo.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-list" aria-hidden="true"></i>&nbsp;VIP套餐管理</a></li> 
     <li class="layui-nav-item" id="mobile"><a href="${ctx}/portal/liveroom/mobileAuthVip.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-phone" aria-hidden="true"></i>&nbsp;VIP手机管理</a></li> 
     <li class="layui-nav-item" id="card"><a href="${ctx}/portal/liveroom/cardAuthVip.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-id-card" aria-hidden="true"></i>&nbsp;VIP卡号管理</a></li> 
     <li class="layui-nav-item" id="manager"><a href="${ctx}/portal/liveroom/manager.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-id-card" aria-hidden="true"></i>&nbsp;管理员设置</a></li> 
     <li class="layui-nav-item" id="portal"><a href="${ctx}/portal/liveroom/portal.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-home" aria-hidden="true"></i>&nbsp;直播间门户</a></li> 
     <li class="layui-nav-item" id="portalView"><a href="${ctx}/portal/liveroom/portalView.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-caret-square-o-right" aria-hidden="true"></i>&nbsp;门户预览</a></li> 
     <li class="layui-nav-item" id="category"><a href="${ctx}/portal/liveroom/category.vo?id=d9c6afa2e0b649afbd56d3c10e6ffc3d"><i class="fa fa-home" aria-hidden="true"></i>&nbsp;活动分类</a></li> 
    </ul> 
   </div> 
   <div class="le-content"> 
    <form id="form" class="layui-form le-layer-from" action="${ctx }/portal/liveroom/saveInfo.vo"> 
     <input type="hidden" name="liveroom.id" value="d9c6afa2e0b649afbd56d3c10e6ffc3d"> 
     <div class="layui-form-item"> 
      <label class="layui-form-label">直播间名称</label> 
      <div class="layui-input-block"> 
       <input type="hidden" name="liveroom.name" lay-verify="title" readonly autocomplete="off" placeholder="直播间名称" class="layui-input" validate="empty" style="border-left:0px;border-top:0px;border-right:0px;border-bottom:1px " value="体验303直播间"> 
       <label style="display:block; padding: 9px 15px 9px 1px;">体验303直播间<span style="color:#999;font-size:10px;">（直播间名称不能修改）</span></label> 
      </div> 
     </div> 
     <div class="layui-form-item"> 
      <label class="layui-form-label">直播间别名</label> 
      <div class="layui-input-block"> 
       <input type="text" name="liveroom.alias" lay-verify="title" autocomplete="off" placeholder="请输入直播间别名" class="layui-input" validate="empty" value="体验303直播间"> 
      </div> 
      <div class="tips" style="color: #999;margin-left: 95px; ">
       提示：建议设置不要超过10个字的别名
      </div> 
     </div> 
     <div class="layui-form-item"> 
      <label class="layui-form-label">直播间简介</label> 
      <div class="live-checkbox"> 
       <textarea name="liveroom.content" validate="empty" placeholder="请输入内容" class="layui-textarea">yy</textarea> 
      </div> 
      <div class="tips" style="color: #999;margin-left: 95px; ">
       提示：建议设置不要超过45个字的简介
      </div> 
     </div> 
     <div class="layui-form-item"> 
      <label class="layui-form-label">直播间图片</label> 
      <div class="layui-input-block"> 
       <div class="le-hardware-layer-image"> 
        <img class="le-avatar" src="http://cdn.lezhibo.com/static/portal/img/default.jpg"> 
       </div> 
       <div class="le-hardware-layer-upload"> 
        <input type="file" name="file" class="layui-upload-file" lay-title="选择"> 
        <input type="hidden" class="avatar" name="liveroom.icon" value=""> 
       </div> 
      </div> 
      <div class="tips" style="color: #999;margin-left: 95px; padding-top: 100px">
       提示：建议上传分辨率为200*200，大小2M以内，格式为PNG、JPG、JPEG等常用格式图片
      </div> 
     </div> 
     <div class="layui-form-item"> 
      <label class="layui-form-label">首页头图</label> 
      <div class="layui-input-block"> 
       <div class="le-hardware-layer-image" style="width:300px;"> 
        <img class="img-header-bg" src="http://cdn.lezhibo.com/attachment/20170822/7e3268d6acb44a5da4ad195dfc26d1d4.jpg"> 
       </div> 
       <div class="le-hardware-layer-upload"> 
        <input btn-leupload le-uploadimg="setHeaderBg()" type="file" name="file" class="layui-upload-file" lay-title="选择"> 
        <input type="hidden" class="header-bg" name="header-bg:header-bg" value="/attachment/20170822/7e3268d6acb44a5da4ad195dfc26d1d4.jpg"> 
       </div> 
      </div> 
      <div class="tips" style="color: #999;margin-left: 95px; padding-top: 100px">
       提示：建议上传分辨率为1000*400，大小2M以内，格式为PNG、JPG、JPEG等常用格式图片
      </div> 
     </div> 
     <div class="layui-form-item"> 
      <label class="layui-form-label">关注人数：</label> 
      <div class="layui-input-block"> 
       <input type="number" name="followers_count:followers_count" value="" class="layui-input" placeholder="请输入直播间关注人数" autocomplete="off"> 
      </div> 
      <div class="tips" style="color: #999;margin-left: 95px; padding-top: 10px">
       提示：设置了关注人数后，会在原有直播间关注人数的基础上
       <strong>加上 </strong>您在此处设置的人数。
      </div> 
     </div> 
     <div class="layui-form-item"> 
      <label class="layui-form-label">关注公众号</label> 
      <div class="layui-input-block"> 
       <div class="le-hardware-layer-image"> 
        <img class="img-qrcode" src="http://cdn.lezhibo.com/attachment/20170822/1cdf578eef724256a2f01d3603f80dd4.jpg"> 
       </div> 
       <div class="le-hardware-layer-upload"> 
        <input btn-leupload le-uploadimg="setQrcode()" type="file" name="file" class="layui-upload-file" lay-title="选择"> 
        <input type="hidden" class="qrcode" name="qrcode:qrcode" value="/attachment/20170822/1cdf578eef724256a2f01d3603f80dd4.jpg"> 
       </div> 
      </div> 
      <div class="tips" style="color: #999;margin-left: 95px; padding-top: 100px">
       提示：建议上传分辨率为300*300，大小2M以内，格式为PNG、JPG、JPEG等常用格式图片
      </div> 
      <div class="layui-form-item" style="margin-top: 10px"> 
       <label class="layui-form-label">公众号底部文字</label> 
       <div class="layui-input-block"> 
        <input type="text" name="metadata:liveroom_wxQRcod_content" lay-verify="title" autocomplete="off" placeholder="请输入公众号底部文字" class="layui-input" validate="empty" value=""> 
       </div> 
       <div class="tips" style="color: #999;margin-left: 95px; ">
         提示：建议设置不要超过15个字的描述 
       </div> 
      </div> 
     </div> 
     <input type="hidden" name="haspic" value="no"> 
     <fieldset class="layui-elem-field layui-field-title le-set-end"> 
      <legend>往期回顾轮播图</legend> 
      <div class="layui-form le-preview-form"> 
       <table class="le-marketing-table le-last-table"> 
        <tbody> 
         <tr> 
          <th>图片</th> 
          <th>链接地址</th> 
          <th>操作</th> 
         </tr> 
         <tr> 
          <td><img class="le-first-ad" src="http://cdn.lezhibo.com/attachment/20170816/36e07a953a03460089b4f1e124910ac9.jpg" data-img-url="/attachment/20170816/36e07a953a03460089b4f1e124910ac9.jpg"></td> 
          <td><input class="le-address-ad layui-input" placeholder="请填写链接地址" type="text"></td> 
          <td><button type="button" class="layui-btn layui-btn-primary layui-btn-small" style="margin: 0" confirm-href="/portal/liveroom/doDelete?liveroomId=d9c6afa2e0b649afbd56d3c10e6ffc3d&amp;dataId=d9c6afa2e0b649afbd56d3c10e6ffc3d&amp;id=2855c0255ac9438c99792e38d9a6dbb4">删除</button></td> 
         </tr> 
         <tr> 
          <td><img class="le-first-ad" src="http://cdn.lezhibo.com/attachment/20170816/ac2acd21a8cb4ce7ba01702273ae9e1a.jpg" data-img-url="/attachment/20170816/ac2acd21a8cb4ce7ba01702273ae9e1a.jpg"></td> 
          <td><input class="le-address-ad layui-input" placeholder="请填写链接地址" type="text"></td> 
          <td><button type="button" class="layui-btn layui-btn-primary layui-btn-small" style="margin: 0" confirm-href="/portal/liveroom/doDelete?liveroomId=d9c6afa2e0b649afbd56d3c10e6ffc3d&amp;dataId=d9c6afa2e0b649afbd56d3c10e6ffc3d&amp;id=81ec7c3a3a224353bb367d7abf34868c">删除</button></td> 
         </tr> 
         <tr class="le-tr-hidden" style="display: none"></tr> 
        </tbody> 
       </table> 
       <div class="le-hidden-data" style="display: none"> 
       </div> 
       <div class="image-tips" style="color: #999;"> 
        <p>图片大小2M以内</p> 
        <p>图片分辨率865*486像素</p> 
        <p>支持PNG、JPG、JPEG格式</p> 
        <p>链接地址是指广告页链接地址</p> 
       </div> 
       <div style="padding-left:10px;">
        <input type="file" btn-leupload le-uploadimg="leLastAd()" name="file" class="layui-upload-file" lay-title="添加">
       </div> 
      </div> 
      <div class="le-preview"> 
       <span>预览</span> 
       <div class="prview-phone"> 
        <div class="preview-img">
         <img src="http://cdn.lezhibo.com/static/portal/images/liveroom-review.gif">
        </div> 
        <div class="preview-phone"></div> 
       </div> 
      </div> 
      <div class="clearfix"></div> 
     </fieldset> 
     <div class="le-hardware-layer-btn" style="float: right;border-top: 0;"> 
      <button type="button" class="layui-btn le-doSubmit" style="margin-bottom: 30px">确定</button> 
     </div> 
    </form> 
    <div class="le-footer"> 
     <p>Copyright © 2015-2017 www.lezhibo.com All rights reserved.</p> 
    </div> 
   </div> 
  </div> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/staticRep/layui/layui.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/staticRep/layui/lay/dest/layui.all.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/static/libs/jquery/jquery.min.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/static/libs/jquery/jquery.form.min.js?cdnv=0.16"></script> 
  <script>
            var cdnPath="http://cdn.lezhibo.com";//cdn路径
            function fix() {
                var head_height = $('.le-head').outerHeight();
                var window_height = $(window).height();
                var content_height = $('.le-content').outerHeight();
                var sidebar_height = $(".le-sidebar").height();
                var max_height = window_height - head_height;
                if(content_height < sidebar_height){
                    content_height = sidebar_height;
                }

                if(max_height < content_height){
                    max_height = content_height;
                }

                $(".le-content").css('min-height', max_height);
                $(".le-sidebar").css('min-height', max_height);


//                if (content_height < (window_height - head_height)) {
//                    $(".le-content").css('min-height', window_height - head_height);
//                } else {
//                    $(".le-sidebar").css('min-height', content_height);
//                    sidebar_height = content_height;
//                }
//
//                if (sidebar_height < (window_height - head_height)) {
//                    $(".le-sidebar").css('min-height', window_height - head_height);
//                }
            }

            var globalNeedRefreshIndex = "";
            var globalNeedRefreshUrl = "";
            var needRefresh = false;

            function openLayer(url, title, func, isNeedRefreshThisPage) {
                var index = layer.open({
                    type: 2,
                    title: title,
                    shadeClose: true,
                    shade: 0.6,
                    area: ['60%', '80%'],
                    content: url,
                    end: function () {
                        if (needRefresh) {
                            layer.iframeSrc(globalNeedRefreshIndex, globalNeedRefreshUrl);//刷新第几层
                            needRefresh = false;
                        }

                        if (!(typeof(func) == "undefined")) {
                            eval(func);
                        }
                    }
                });

                if (isNeedRefreshThisPage == true) {
                    globalNeedRefreshIndex = index;
                    globalNeedRefreshUrl = url;
                }

            }

            function layerInit() {
                $("[layer-href]").click(function () {
                    if ("" == $(this).attr("layer-need-record")) {
                        openLayer($(this).attr("layer-href"), $(this).attr("layer-title"), $(this).attr("layer-func"), true);
                    } else {
                        openLayer($(this).attr("layer-href"), $(this).attr("layer-title"), $(this).attr("layer-func"), false);
                    }
                });

                $("[go-href]").click(function () {
                    var href = $(this).attr("go-href");
                    var newWind = $(this).attr("go-href-new");
                    if (newWind == "true") {
                        window.open(href);
                    } else {
                        window.location.href = href;
                    }
                });


                $("[confirm-href]").click(function () {
                    var href = $(this).attr("confirm-href");
                    if ((typeof(href) == "undefined") || href == null || href == "") {
                        return;
                    }

                    var title = $(this).attr("confirm-title");
                    if ((typeof(title) == "undefined") || title == null || title == "") {
                        title = "您确定执行该操作吗？"
                    }
                    layer.confirm(title, {icon: 9, title: '确定操作 ？'}, function (index) {
                                layer.close(index);
                                $.get(href, function (result) {
                                    if (result.isOk) {
                                        location.reload();
                                    } else {
                                        alert(result.message);
                                    }
                                });
                            },
                            function (index) {
                                layer.close(index);
                            });
                });


            }

            function headerFocus() {
                $("#nav-liveroom").addClass("layui-this");
            }


            function initSidebarUrls() {

                $(".le-sidebar").find(".layui-nav-item").each(function () {
                    var pid = $(this).attr("id");
                    if (typeof(pid) == 'undefined' || null == pid) {
                        return;
                    }

                    var href = $(this).children('a').attr("href");
                    if ((typeof(href) != "undefined") && href.indexOf("?") == -1) {
                        href = href + "?p=" + pid;
                    } else {
                        href = href + "&p=" + pid;
                    }
                    $(this).attr("class", "layui-nav-item");
                    $(this).children('a').attr("href", href);
                });

                $("#info").attr("class", "layui-nav-item layui-this");
            }

            var verification = {
                mobiel: function () {
                    $mobile = $("input[validate='mobile']").val();
                    var re = /^1\d{10}$/;
                    if ((typeof($mobile) != "undefined") && !re.test($mobile)) {
                        $("input[validate='mobile']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入正确的手机号</span></p>');
                        return false;
                    }
                },
                email: function () {
                    $email = $("input[validate='email']").val();
                    var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                    if ((typeof($email) != "undefined") && !re.test($email)) {
                        $("input[validate='email']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入正确的邮箱</span></p>');
                        return false;
                    }
                },
                empty: function () {
                    var $input = $("input[validate='empty']");
                    for (var i = 0; i < $input.length; i++) {
                        if ($input.eq(i).val().trim().length == 0) {
                            $("input[validate='empty']").eq(i).after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                            return false;
                        }
                    }

                    var $textarea =$("textarea[validate='empty']");
                    for(var i=0;i<$textarea.length;i++){
                        if($textarea.eq(i).val().trim().length==0){
                            $("textarea[validate='empty']").eq(i).after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                            return false;
                        }
                    }
                },

                password: function () {
                    $password = $("input[validate='password']").val();
                    var re = /(.+){6,12}$/;
                    if ((typeof($password) != "undefined") && !re.test($password)) {
                        $("input[validate='password']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入6到12位密码</span></p>');
                        return false;
                    }
                },
                //正整数
                positiveInteger: function () {
                    $positiveInteger = $("input[validate='positiveInteger']");
                    var re=/^[1-9]\d*|0$/;
                    for (var i = 0; i < $positiveInteger.length; i++) {
                        var every=$positiveInteger.eq(i).val().trim();
                        if ((typeof(every) != "undefined") && !re.test(every)) {
                            $("input[validate='positiveInteger']").eq(i).after('<p class="le-tips"><span style="color: red">请输入一个正整数或者0</span></p>');
                            return false;
                        }
                    }
                },
                decimal: function (value) {
                   $decimal = $("input[validate='decimal']");
                    var re = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                    for (var i = 0; i < $decimal.length; i++) {
                        var every=$decimal.eq(i).val().trim();
                        if ((typeof(every) != "undefined") && !re.test(every)) {
                            $("input[validate='decimal']").eq(i).after('<p class="le-tips"><span style="color: red">值不能小于0</span></p>');
                            return false;
                        }
                    }
                }
            };


            var regularVerify = {
                mobile: function (value) {
                    var re = /^1\d{10}$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                email: function (value) {
                    var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                password: function (value) {
                    var re = /(.+){6,12}$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                integer: function (value)     {
//                    var re = /^[1-9]\d*$/;
                    var re = /^\d+$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                decimal: function (value) {
//                    var re = /^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$/;
                    var re = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                empty: function (value) {
                    if (value.trim().length == 0) {
                        return false;
                    }
                }
            }


            function leSubmit() {
                $("[le-submit]").click(function () {
                    var $form = $(this).parents("form");
                    var sfunc = $form.attr("success-func");
                    var bfunc = $form.attr("before-func");
                    $form.ajaxSubmit({
                        type: "post",
                        dataType: "json",
                        beforeSend: function () {
                            if(bfunc != null){
                                if(false == eval(bfunc)){
                                    return false;
                                }
                            }
                            $(".le-tips").remove();
                            if (false == verification.empty()) {
                                return false;
                            }
                            if (false == verification.mobiel()) {
                                return false;
                            }
                            if (false == verification.email()) {
                                return false;
                            }
                            if (false == verification.password()) {
                                return false;
                            }
                        },
                        success: function (result) {
                            if (sfunc != null) {
                                eval(sfunc);
                                return;
                            }

                            if (result.isOk) {
                                parent.isUpdateData = true;
                                parent.layer.closeAll();
                            } else {
                                alert(result.message);
                            }
                        },
                        error: function () {
                            alert("信息提交错误");
                        }
                    });
                })
            }

            //对日期选择范围的控制
            //对id为begin-date和end-date的日期选择控件进行控制
            function verifyDate() {
                layui.use('laydate', function () {
                    var laydate = layui.laydate;
                    var start = {
                        min: '2006-01-01 00:00:00',
                        max: '2099-06-16 23:59:59',
                        istoday: false,
                        choose: function (datas) {
                            end.min = datas;    //开始日选好后， 重置结束日的最小日期
                            end.start = datas;  //将结束日的初始值设定为开始日
                        }
                    };

                    var end = {
                        min: '2006-01-01 00:00:00',
                        max: '2099-06-16 23:59:59',
                        istoday: false,
                        choose: function (datas) {
                            start.max = datas;  //结束日选好后, 重置开始日的最大日期
                        }
                    };

                    $('.begin-date').click(function () {
                        start.elem = this;
                        laydate(start);
                    });
                    $('.end-date').click(function () {
                        end.elem = this;
                        laydate(end);
                    });

                });
            }

            fix();
            layerInit();
            headerFocus();
            initSidebarUrls();
            leSubmit();
            verifyDate();


//<script>


    $(function(){
    setTimeout(function (){
    var window_height = $(window).height();
    var head_height = $('.le-head').outerHeight();
    var content_height = $('.le-content').outerHeight();
    if(content_height < window_height - head_height){
    content_height = window_height - head_height;
    $(".le-content").css("height",content_height);
    }
    $(".le-sidebar").css("height",content_height);
    }, 100);
    });

    //上传图片
    var upfun=null;
    var leImgUrl ="";
    var leCdnImgUrl = "";
    $("[btn-leupload]").change(function(){
        upfun =  $(this).attr("le-uploadImg");
    })

    layui.upload({
        url: '/portal/attachment/upload',
        success: function(result){
            if(result.isOk){
                leImgUrl = result.path;
                leCdnImgUrl = result.cdnPath;
                if (upfun != null) {
                    eval(upfun);
                    upfun=null;
                    return;
                }
                $(".avatar").val(result.path);
                $(".le-avatar").attr("src",result.cdnPath);
            }else{
                alert(result.message);
            }
        },
        error:function(){
            alert("信息提交错误");
        }
    });

    //往期回顾广告图
    function leLastAd(){
        $("input[name='haspic']").val("yes");
        var data = Math.random();
        var html = "";
        html +='<tr><td><img class="le-first-ad "  src="'+leCdnImgUrl+'" data-img-url="'+leImgUrl+'"></td>';
        html +='<td><input class="layui-input le-address-ad" placeholder="请填写链接地址" autocomplete="off" type="text"></td>';
        html +='<td><button type="button" class="layui-btn layui-btn-primary layui-btn-small le-delete" onclick="removeLastAd(this)">删除</button></td>';
        html +='</td></tr>';
        $(".le-tr-hidden").before(html);

    }

    function removeLastAd(obj){
        $(obj).parents("tr").remove();
    }

    //直播间背景图设置
    function setHeaderBg(){
        $(".header-bg").val(leImgUrl);
        $(".img-header-bg").attr("src", leCdnImgUrl);
    }

    //关注二维码设置
    function setQrcode(){
        $(".qrcode").val(leImgUrl);
        $(".img-qrcode").attr("src", leCdnImgUrl);
    }

    $(document).on("click",".le-doSubmit",function(){
        var $num = $(".le-first-ad").size();
        var html = "";
        for(var i=0;i<$num;i++){
            var $img = $(".le-first-ad").eq(i).attr("data-img-Url");
            var $addr = $(".le-address-ad").eq(i).val();
            html+='<input type="hidden" name="historyReview:leAdList'+i+'" value="'+$img+'#lzb#'+$addr+'">';
        }
    console.log(html+"le-last-ad-img");
        $(".le-hidden-data").html(html);

        $("#form").ajaxSubmit({
            type : "post", //提交方式
            dataType : "json", //数据类型
            beforeSubmit : function(){

                if($("input[name='liveroom.alias']").val().trim().length==0){
                    alert("直播间别名不能为空!");
                    return false;
                }
                if($("textarea[name='liveroom.content']").val().trim().length==0){
                    alert("直播间简介不能为空!");
                    return false;
                }
                if($("input[name='liveroom.id']").val().trim().length==0){
                    $(".le-doSubmit").attr("class","layui-btn layui-btn-disabled");
                    $(".le-doSubmit").attr("disabled","disabled");
                    $(".le-doSubmit").attr('onclick','javascript:void(0);');
                }
            },
            success : function(result){ //提交成功的回调函数
                if(result.isOk){
                    alert(result.object);
                    //parent.isUpdateData = true;
                    location.reload();
                    //parent.layer.closeAll();
                }else{
                    alert(result.message);
                    $(".le-doSubmit").attr("class","layui-btn");
                }
            },
            error : function() {
                alert("信息提交错误");
                $(".le-doSubmit").attr("class","layui-btn");
            }
        });
    })
    //</script>    
 </body>
</html>